<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="left">开灯</button>
    <button id="right">关灯</button>
    <script>
        var left = document.getElementById('left');
        var right = document.getElementById('right');
        var body = document.getElementsByTagName('body')[0];

        left.onclick = function() {

            body.style.backgroundColor = 'white';
            right.onclick = function() {
                body.style.backgroundColor = 'black';

            }
        }
    </script>
</body>

</html>